<html>
<head><meta charset="utf-8"><title>Implementation · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html">Implementation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244265623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/244265623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#244265623">(Jun 29 2021 at 11:28)</a>:</h4>
<p>I've been able to start implementation work in earnest, but could use some mentoring. How do you add a lang item? I've made what I (think) are the necessary modifications to:</p>
<ul>
<li><code>compiler/rustc_hir/src/lang_items.rs</code></li>
<li><code>compiler/rustc_span/src/symbol.rs</code></li>
</ul>
<p>...and then added <code>BikeshedTransmutableFrom</code> to <code>library/core/src/mem/mod.rs</code> and annotated it with <code>#[lang = "transmute_trait"]</code>.</p>
<p>Does this sound generally correct?  <code>./x.py check</code> yields:</p>
<div class="codehilite"><pre><span></span><code>error[E0522]: definition of an unknown language item: `transmute_trait`
 --&gt; library/core/src/mem/transmutability.rs:3:1
  |
3 | #[lang = &quot;transmute_trait&quot;]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown language item `transmute_trait`
</code></pre></div>
<p>I'm wondering if there's anything else I need to do, like re-bootstrap the compiler since this change touches both the compiler and libcore?</p>
<p>cc <span class="user-mention" data-user-id="232957">@Jack Huey</span>, <span class="user-mention" data-user-id="125250">@Wesley Wiser</span></p>



<a name="244286224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/244286224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#244286224">(Jun 29 2021 at 14:06)</a>:</h4>
<p>Yeah, as you alluded to, the issue is that for the stage0 compiler, the <code>Transmute</code> trait isn't a lang item. What you'll need to do is conditionally apply the lang item attribute if it isn't the stage0 compiler like this:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#[cfg_attr(not(bootstrap), lang = </span><span class="s">"transmute_trait"</span><span class="cp">)]</span><span class="w"></span>
</code></pre></div>
<p>I think that is all you'll need to do. Whoever updates the beta compiler next will then remove the condition since it will be required in that version.</p>



<a name="244316213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/244316213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#244316213">(Jun 29 2021 at 17:20)</a>:</h4>
<p>If you'd like an example  <span class="user-mention" data-user-id="219211">@Jack Wrenn</span>, my <code>?</code> PR changed some <a href="https://github.com/rust-lang/rust/pull/84767/files#diff-f82976cf19f74035c16523680a66b66ddb6f25220a531a5485b58dada8fb7ccc">https://github.com/rust-lang/rust/pull/84767/files#diff-f82976cf19f74035c16523680a66b66ddb6f25220a531a5485b58dada8fb7ccc</a> and then the bootstrap update PR later updates the <code>cfg(bootstrap)</code>s <a href="https://github.com/rust-lang/rust/pull/86603/files#diff-49412431a58f2ca62539b01666601bb34bcc133f35049a6c6d32c0c1ae891084">https://github.com/rust-lang/rust/pull/86603/files#diff-49412431a58f2ca62539b01666601bb34bcc133f35049a6c6d32c0c1ae891084</a></p>



<a name="245357698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/245357698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#245357698">(Jul 08 2021 at 19:09)</a>:</h4>
<p>Hi all, I've recently started reading up on the safe transmute project and it sounds like an interesting and useful feature. From what I can gather on the status, it seems like most of the design questions are resolved and mostly what's left is implementation. Is that right? Are there areas in the project that could use help?</p>



<a name="245376355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/245376355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pachi <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#245376355">(Jul 08 2021 at 21:44)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> is working on the implementation and I think he expressed that some help would be very welcome!</p>



<a name="245384127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/245384127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#245384127">(Jul 08 2021 at 23:24)</a>:</h4>
<p>Yep! I <em>think</em> I have a decent idea of what an algorithm for checking transmutability might look like, and I'm at the very early stages of implementation. I'm currently in the midst of a stressful move and job search, but will be increasingly working on this again after August 1.</p>



<a name="245384656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/245384656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#245384656">(Jul 08 2021 at 23:31)</a>:</h4>
<p>Sounds good. Good luck on the move and the job search!</p>



<a name="245384769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Implementation/near/245384769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eholk <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Implementation.html#245384769">(Jul 08 2021 at 23:32)</a>:</h4>
<p>Do you have any notes anywhere, or is any of your implementation available to look at?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>